<?php
/**
 * @package tests
 */
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../../plugins/GraduaUtil/lib/test/Gradua_PHPUnit_Framework_TestCase.php';
/**
 * @see JsCall
 */
class JsCallTest extends Gradua_PHPUnit_Framework_TestCase
{

    /**
     * The source code:
     * {@source}
     */
    public function testShouldBuildValidJSON()
    {
	   $json = JsCall::build()
	   ->addCommand('TestC','execute')->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
	   $json = 
	     JsCall::build()
	     ->addCommand('TestC','execute')
	     ->addPHPParam('param1',"umaString")
	     ->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
	   $json = 
	     JsCall::build()
	     ->addCommand('TestC','execute')
	     ->addPHPParam('param1',5)
	     ->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
	   $json = 
	     JsCall::build()
	     ->addCommand('TestC','execute')
	     ->addPHPParam('param1',"umaString")
	     ->addPHPParam('param2',5)
	     ->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
	   $json = 
	     JsCall::build()
	     ->addCommand('TestC','execute')
	     ->addCommand('c2','e2')
	     ->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
	   $json = 
	     JsCall::build()
	     ->addCommand('TestC','execute')
	     ->addPHPParam('param1',"umaString")
	     ->addPHPParam('param2',5)
	     ->addCommand('c3','e3')
	     ->addPHPParam('pram',5)
	     ->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
	   $json = 
	     JsCall::build()
	     ->addCommand('TestC','execute')
	     ->addJsonParam('param1','{"propertie":2}')
	     ->toJson();
	   $this->assertTrue(is_object(json_decode($json)));
    }    
}